﻿#include "../HMessagePanel.h"
#include "../../include/HGlobalVariable.h"
#include "../../include/StdAfx.h"

HMessagePanel::HMessagePanel(QWidget *parent)
    :HMoveableWidget(parent)
{

    setWindowFlags(Qt::FramelessWindowHint | Qt::Window);
    setWindowModality(Qt::ApplicationModal);
    setFixedSize(304,159);

    m_strText = QString::fromLocal8Bit("已有广播在此音频设备上进行...");

    m_ppbOK = new QPushButton(this);
    m_ppbOK->setText(QString::fromLocal8Bit("确定"));
    m_ppbOK->setFixedSize(NSAVEBTNWIDTH,NSAVEBTNHEIGHT);
    m_ppbOK->setObjectName("setting_btn_cancel");

    m_plblText = new QLabel(this);
    m_plblText->setText(m_strText);
    m_plblText->setAlignment(Qt::AlignCenter);
	m_plblText->setObjectName("dc_lbl_sliderSpeed");

    m_pvblMain = new QVBoxLayout();
    m_pvblMain->setContentsMargins(20,20,20,20);
    m_pvblMain->setSpacing(20);

    m_pvblMain->addWidget(m_plblText,1,Qt::AlignHCenter);
    m_pvblMain->addWidget(m_ppbOK,1,Qt::AlignHCenter);

    setLayout(m_pvblMain);
	
	initStyle();

    connect(m_ppbOK,SIGNAL(clicked()),this,SLOT(close()));

}

HMessagePanel::~HMessagePanel()
{

}

void HMessagePanel::paintEvent(QPaintEvent *event)
{
	QStyleOption opt;
	opt.init(this);
	QPainter p(this);
	style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
	QWidget::paintEvent(event);
}

void HMessagePanel::setText(QString strText)
{
    m_strText = strText;
    m_plblText->setText(m_strText);
}


void HMessagePanel::initStyle()
{
    setObjectName("dc_wnd_popScreenSelect");
    QFile file(g_strAppPath + QSSRELATIONPATH + "HLoginPanel.qss");
    QFile file1(g_strAppPath + QSSRELATIONPATH + "HDomeControlPanel.qss");
    if(file.open(QIODevice::ReadOnly) && file1.open(QIODevice::ReadOnly))
    {
        QString strStyle = file.readAll();
        strStyle.append(file1.readAll());

        setStyleSheet(strStyle.arg(g_strAppPath + g_strImageRelationPath));

        file.close();
        file1.close();
    }

}
